package day19;

import java.util.Scanner;

/**
 * @author tongchen
 * @create 2023-03-26 22:57
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
     while(scanner.hasNextInt()){
         int n=scanner.nextInt();
         if(n==0){
             return;
         }
         int count=0;
         while(n>=3){
             int k=n/3;
             count+=k;
             n=n%3;
             n+=k;
         }
         if(n==2){
             count+=1;
         }
         System.out.println(count);
     }

    }
}
